
#案例一
# from langchain_core.tools import tool
# @tool
# def multiply(a: int, b: int) -> int:
#     """Multiply two numbers together."""
#     return a * b
#
# print("工具名称:",multiply.name)
# print("工具描述:",multiply.description)
# print("工具参数:",multiply.args)
# print("工具返回值:",multiply.return_direct)
# print("工具详细的schema:",multiply.args_schema.model_json_schema())
#
# print(multiply.invoke({"a": 2, "b": 3}))

#案例二
from pydantic import BaseModel,Field
from langchain_core.tools import tool

class CalculatorInput(BaseModel):
    a:int = Field(description="第一个参数")
    b:int = Field(description="第二个参数")

@tool("multiplication-tool",args_schema=CalculatorInput,return_direct=True)
def multiply(a: int, b: int) -> int:
    """Multiply two numbers together."""
    return a * b

print("工具名称:",multiply.name)
print("工具描述:",multiply.description)
print("工具参数:",multiply.args)
print("工具返回值:",multiply.return_direct)
print("工具详细的schema:",multiply.args_schema.model_json_schema())